/*
 * cardTest.java
 */

package organiser;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author Robin Gjurovski
 */

public class cardTest implements ActionListener {
    private JFrame frame = new JFrame("Cardtest");
    private JPanel cards;
    private final static String BUTTONPANEL = "ruta1";
    private final static String TEXTPANEL = "ruta2";
    private JPanel card1 = new JPanel();
    private JPanel card2 = new JPanel();
    private JButton b1 = new JButton("HEJ1");
    private JButton b2 = new JButton("HEj2");

    public cardTest(){
        Container c = frame.getContentPane();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
        
        card1.add(b1);
        card1.add(b2);
        card1.add(new JButton("Button 3"));
        b1.addActionListener(this);
        b2.addActionListener(this);

        card2.add(new JTextField("TextField", 20));

        cards = new JPanel(new CardLayout());

        cards.add(card1, "ruta2");
        cards.add(card2, "ruta1");

        c.add(cards, BorderLayout.CENTER);

        frame.pack();
        
    }
    
    public static void main(String[] args) {
        cardTest t = new cardTest();
    }

    public void actionPerformed(ActionEvent e) {
        Object source = e.getSource();
        CardLayout cl = (CardLayout)(cards.getLayout());
        if(source ==(b1)){
            cl.show(cards, "ruta1");
        }
        else if(source == b2){
            cl.show(cards, "ruta1");
        }
    }


}
